﻿Imports Global_Visas_Business_Layer
Partial Public Class frmEnableOnlinePayment
    Public Enum AccessMethod
        Enable = 1
        Disable = 2
    End Enum
    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnOK.Click
        Dim sEnable As Integer = 0
        If txtCaseId.Text <> "" Then
            If IsNumeric(Me.txtCaseId.Text) Then
                If CommonFuncs.IDSearch(txtCaseId.Text, 3) = "ok" Then
                    If rdoEnable.IsChecked = True Then
                        sEnable = AccessMethod.Enable
                    ElseIf rdoDisable.IsChecked = True Then
                        sEnable = AccessMethod.Disable
                    ElseIf rdoEnable.IsChecked = False And rdoDisable.IsChecked = False Then
                        sEnable = 0
                    End If
                    If sEnable > 0 Then
                        If Admin.ForceEnableOnlinePayment(txtCaseId.Text, sEnable) = True Then
                            'log event
                            Dim taskEvents As New TasksEvents()
                            If sEnable = AccessMethod.Enable Then
                                taskEvents.GblFunc_Add_Event("Online Payment", "The access to the online Payment Link is forcefully given through the admin section of CRM.", TasksEvents.EventStatus.SingleEvent, txtCaseId.Text, TasksEvents.EventTypes.EventCase)
                                MsgBox("The Online Payment access has been provided for the caseid :" & txtCaseId.Text, MsgBoxStyle.Information, "Success")
                            ElseIf sEnable = AccessMethod.Disable Then
                                taskEvents.GblFunc_Add_Event("Online Payment", "The access to the online Payment Link is forcefully disabled through the admin section of CRM.", TasksEvents.EventStatus.SingleEvent, txtCaseId.Text, TasksEvents.EventTypes.EventCase)
                                MsgBox("The Online Payment access has been disabled for the caseid :" & txtCaseId.Text, MsgBoxStyle.Information, "Success")
                            End If
                            Me.Close()
                        Else
                            MsgBox("The Online Payment access change is not successful.Please try again", MsgBoxStyle.Critical, "Failure")
                        End If
                    Else
                        MsgBox("Please choose the option to enable or disable the forced online payment for the case", MsgBoxStyle.Information, "Payment Access")
                    End If
                Else
                    MsgBox("Case id not found in the system. Please check the case id", MsgBoxStyle.Information, "case ID")
                End If
            Else
                MsgBox("Please enter a valid case id", MsgBoxStyle.Information, "case ID")
            End If
        End If
    End Sub


    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        GeneralTasks.ChangeTheme(Me)
        GeneralTasks.EnumerateandFill(Me.LogicalChildren)
    End Sub
End Class
